/*******************************************************************************************************
* SETTINGS
********************************************************************************************************/
$.Questionnaire.sendDataTo('http://m.cip.gatech.edu/developer/wrecklist/api/homeless/savePostData/');
// Currently the questionnaire is set to start at '13' because I want to test question 13.
// You can set it to whatever you want for your testing purpose.
$.Questionnaire.first('1');

/*******************************************************************************************************
* QUESTIONS
*******************************************************************************************************/



//----------------------------------Text_anwers----------------------------------------------------------------------
$.Questions['1']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Interviewers Name',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#text_answer',
		answer_units: ['Interviewers Name'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						interviewer: $(pageElement).find('.value').first().val()
					});
				$.Questionnaire.next('2'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.


//-----------------------------------Radio_other answers---------------------------------------------------------------------
$.Questions['2']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Agency Information',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_other_answer',
		answer_choices: ['Staff', 'Volunteer'],
		text_input: 'Agency Name',
		process_values: function(pageElement, nextQuestionButton){
				var obj={};

				$.Questionnaire.save({
							staff_or_volunteer: $(nextQuestionButton).attr('data-choice-value'),
							 agency_info: $(pageElement).find('.tentry').first().val()
					});	
				
				$.Questionnaire.save({
						current_UTC_date_time: (new Date()).toUTCString()
					});
				
				navigator.geolocation.getCurrentPosition(function(Position){
						$.Questionnaire.save({
								current_geolocation_latitude:Position.coords.latitude,
								current_geolocation_longitude:Position.coords.longitude
							});
						if (navigator.camera)
							navigator.camera.getPicture(function(dataURI){
									$.Questionnaire.save({
											picture_data_URI:dataURI 
										});
									$.Questionnaire.next('6');
								},function(){
									$.Questionnaire.next('6');
								},{
									quality: 50,
									destinationType: 0 /*Camera.DestinationType.DATA_URL*/
								});
						else
							$.Questionnaire.next('6');
					},function(){
						$.Questionnaire.next('3');
					},{enableHighAccuracy:true});
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//---------------------------text_answer---------------------------
$.Questions['3']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'DO NOT ASK: Where are you right now?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#text_answer',
		answer_units: ['Location'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						current_location: $(pageElement).find('.value').first().val()
					});
				if (navigator.camera)
					navigator.camera.getPicture(function(dataURI){
							$.Questionnaire.save({
									picture_data_URI:dataURI 
								});
							$.Questionnaire.next('6');
						},function(){
							$.Questionnaire.next('6');
						},{
							quality: 50,
							destinationType: 0 /*Camera.DestinationType.DATA_URL*/
						});
				else
					$.Questionnaire.next('6');
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//---------------------------text_answer---------------------------
$.Questions['6']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'In what language do you feel best able to express yourself?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#text_answer',
		answer_units: ['Language'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						language: $(pageElement).find('.value').first().val()
					});
				$.Questionnaire.next('7'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.


//---------------------------text_answer---------------------------
$.Questions['7']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'First Name',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#text_answer',
		answer_units: ['First Name'],
		process_values: function(pageElement, nextQuestionButton){	
				$.Questionnaire.save({
						first_name: $(pageElement).find('.value').first().val()
					});
				$.Questionnaire.next('8'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//---------------------------text_answer---------------------------
$.Questions['8']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Last Name',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#text_answer',
		answer_units: ['Last Name'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						last_name: $(pageElement).find('.value').first().val()
					});
				$.Questionnaire.next('9'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//---------------------------text_answer---------------------------
$.Questions['9']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Nick Name',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#text_answer',
		answer_units: ['Nick Name'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						nick_name: $(pageElement).find('.value').first().val()
					});
				$.Questionnaire.next('10'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------Text_anwers----------------------------------------------------------------------
$.Questions['10']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Date of Birth',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#text_answer',
		answer_units: ['DOB'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						dob: $(pageElement).find('.value').first().val()
					});
				$.Questionnaire.next('11'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.


//-----------------------------------Numeric_answers---------------------------------------------------------------------
$.Questions['11']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Social Security Number',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#numeric_answer',
		answer_units: ['SSN'],
		process_values: function(pageElement, nextQuestionButton){
				var values=[];
				// assuming the input elements have class="value" and data-unit="years", etc.
				$(pageElement).find('.value').each(function(valueIndex,valueElement){
						values[$(valueElement).attr('data-unit')]=parseInt($(valueElement).val());
					});
				$.Questionnaire.save({
						ssn: values['SSN']
					});
				
				var createHash=function(str) {
					    var hash = 0, i, char;
					    if (str.length == 0) return hash;
					    for (i = 0; i < str.length; i++) {
					        char = str.charCodeAt(i);
					        hash = ((hash<<5)-hash)+char;
					        hash = hash & hash; // Convert to 32bit integer
					    }
					    return Math.abs(hash);
					};
				
				window.getCurrentSurveyID=function(){
						return $.Questionnaire.currentQuestionData.unique_survey_id;
					};

				$.Questionnaire.save({
						unique_survey_id: createHash(createHash($.Questionnaire.currentQuestionData.interviewer)+'-'+createHash($.Questionnaire.first_name+'  '+$.Questionnaire.last_name+'  '+$.Questionnaire.nick_name+'  '+$.Questionnaire.dob+'  '+$.Questionnaire.ssn)+'-'+createHash(Math.random()+''))
					});
				
				$.Questionnaire.next('12'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.


//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['12']={
		question_template_selector: '#survey_id_question', // in oppose to the "DO NOT ASK" questions
		question: 'Interviewer: Please write down the following ID on the survey form:',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Has signed and given consent to participate','Has not signed nor given consent to participate'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						consent_to_participate: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('13'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.


//-----------------------------------Numeric_answers---------------------------------------------------------------------
$.Questions['13']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'What is the total length of time you have lived on the streets or shelters?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#numeric_answer',
		answer_units: ['years', 'months'],
		process_values: function(pageElement, nextQuestionButton){
				var values=[];
				// assuming the input elements have class="value" and data-unit="years", etc.
				$(pageElement).find('.value').each(function(valueIndex,valueElement){
						values[$(valueElement).attr('data-unit')]=parseInt($(valueElement).val());
					});
				$.Questionnaire.save({
						years_on_the_street: values['years'],
						months_on_the_street: values['months']
					});
				$.Questionnaire.next('14'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//-----------------------------------Numeric_answers---------------------------------------------------------------------
$.Questions['14']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'In the past three years, how many times have you been homeless and then housed again?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#numeric_answer',
		answer_units: ['times homeless'],
		process_values: function(pageElement, nextQuestionButton){
				var values=[];
				// assuming the input elements have class="value" and data-unit="years", etc.
				$(pageElement).find('.value').each(function(valueIndex,valueElement){
						values[$(valueElement).attr('data-unit')]=parseInt($(valueElement).val());
					});
				$.Questionnaire.save({
						times_homeless: values['times homeless']
					});
				$.Questionnaire.next('15'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.


//-----------------------------------Radio_other answers---------------------------------------------------------------------
$.Questions['15']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Where do you sleep most frequently?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_other_answer',
		answer_choices: ['Shelter','Outside(street,camp,park)','Car/Van/RV', 'Someone else\'s place'],
		text_input: 'Specify',
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						sleeping_location: nextQuestionButton.attr('data-choice-value'),
							 sleeping_location_other: $(pageElement).find('.tentry').first().val()
					});
				$.Questionnaire.next('16'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//-----------------------------------Radio_other answers---------------------------------------------------------------------
$.Questions['16']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Where did you live prior to becoming homeless?(location of last permanent residence)',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_other_answer',
		answer_choices: ['This city','This region','Another Place in Georgia', 'Location outside of Georgia'],
		text_input: 'Zip Code: ',
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						living_location: $(nextQuestionButton).attr('data-choice-value'),
							 zip: $(pageElement).find('.tentry').first().val()
					});
				$.Questionnaire.next('17'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.



//-------------------------------------checkbox answer-----------------------------------------------
$.Questions['17']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'How did you arrive at this location(where you are sleeping)?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#checkbox_answer',
		answer_choices: ['Bus', 'Marta', 'Drove', 'Rode in someone else\'s car', 'Biked', 'Walked', 'Other'],
		process_values: function(pageElement, nextQuestionButton){
				var obj={};
				
				// assuming the input elements have class="value" and data-unit="years", etc.
				$(pageElement).find('.choices').each(
					function(index, choice)
					{ 
						obj['location_arrival_'+$(choice).val()] = $(choice).prop('checked'); 
					})
				$.Questionnaire.save(obj);
				$.Questionnaire.next('18'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//-----------------------------------Numeric_answers---------------------------------------------------------------------
$.Questions['18']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'How many times have you been to the emergency room in the past three months?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#numeric_answer',
		answer_units: ['times'],
		process_values: function(pageElement, nextQuestionButton){
				var values=[];
				// assuming the input elements have class="value" and data-unit="years", etc.
				$(pageElement).find('.value').each(function(valueIndex,valueElement){
						values[$(valueElement).attr('data-unit')]=parseInt($(valueElement).val());
					});
				$.Questionnaire.save({
						emergency_room_visits: values['times']
					});
				$.Questionnaire.next('19'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//-----------------------------------Numeric_answers---------------------------------------------------------------------
$.Questions['19']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'How many times have you been hospitalized as an inpatient in the past year?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#numeric_answer',
		answer_units: ['times hospitalized'],
		process_values: function(pageElement, nextQuestionButton){
				var values=[];
				// assuming the input elements have class="value" and data-unit="years", etc.
				$(pageElement).find('.value').each(function(valueIndex,valueElement){
						values[$(valueElement).attr('data-unit')]=parseInt($(valueElement).val());
					});
				$.Questionnaire.save({
						times_hospitalized: values['times hospitalized']
					});
				$.Questionnaire.next('20a'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------------radio answer----------------------------------------------------------------
// 20a = 20 part a
$.Questions['20a']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Do you have now, have you ever had, or has a healthcare provider ever told you that you have any of the following medical conditions?\n A. Kidney disease/End State Renal Disease or Dialysis',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						medical_cond_a: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('20b'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.


//----------------------------------------radio answer----------------------------------------------------------------
//20b = 20 part b
$.Questions['20b']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'B. History of frostbite, Hypothermia, or Immersion Foot',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						medical_cond_b: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('20c'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.


//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['20c']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'C. History of Heat Stroke/Heat Exhaustion',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						medical_cond_c: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('20d'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['20d']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'D. Liver disease, Cirrhosis, or End-Stage Liver Disease',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						medical_cond_d: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('20e'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['20e']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'E. Heart disease, Cardiovascular, Arrhythmia, High Blood Pressure or Irregular Heartbeat',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						medical_cond_e: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('20f'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['20f']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'F. HIV+/AIDS',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						medical_cond_f: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('20g'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['20g']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'G. Emphysema',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						medical_cond_g: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('20h'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['20h']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'H. Diabetes',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						medical_cond_h: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('20i'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['20i']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'I. Asthma',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						medical_cond_i: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('20j'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['20j']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'J. Cancer',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						medical_cond_j: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('20k'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['20k']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'K. Hepatitis C',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						medical_cond_k: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('20l'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['20l']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'L. Tuberculosis',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						medical_cond_l: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('20m'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['20m']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'M. Are these medical conditions under treatment?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						medical_cond_m: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('20n'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['20n']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: '	DO NOT ASK: Surveyor, do you observe signs or symptoms of serious physical health conditions?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						medical_cond_n: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('21'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['21']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Have you ever abused drug/alcohol, or been told you do?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						substance_abuse: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('22'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['22']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Have you consumed alcohol everyday for the past month?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						everyday_drinking_alcohol_for_past_month: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('23'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['23']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Have you ever used injection drugs or shots?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						injection_drugs: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('24'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['24']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Have you ever been treated for drug or alcohol abuse?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						substance_abuse_treatment: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('25'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.


//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['25']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'DO NOT ASK: Surveyor, do you observe signs of symptoms of alcohol or drug abuse?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						observe_symptioms_of_alcohol_or_drug_abuse: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('26'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.


//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['26']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Have you ever been told that you were diagnosed with a mental health issue?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						diagnosed_mental_health: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('27'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['27']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Are you currently/have you ever received treatment for mental health issues?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						mental_health_treatment: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('28'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.
//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['28']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Have you ever been hospitalized for a psychiatric disorder or mental health reasons?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						mental_health_hospitalization: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('29'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.


//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['29']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'DO NOT ASK: Surveyor, do you detect signs or symptoms of severe, persistent mental illness?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						detect_mental_illness: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('30'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['30']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Have you been the victim of a violent attack since you\'ve become homeless?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						victim_of_violent_attack_since_homeless: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('31'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['31']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Do you have a permanent physical disability that limits your mobility? [i.e., wheelchair, amputation, unable to climb stairs]',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						permanent_physical_disability: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('32'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['32']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Have you had a serious brain injury or head trauma that required hospitalization or surgery?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						brain_injury: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('33'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------------radio answer----------------------------------------------------------------
$.Questions['33']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'In general, would you describe your health as...',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Excellent','Very Good','Good','Fair', 'Poor'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						self_evaluated_health: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('34'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//-----------------------------------Numeric_answers---------------------------------------------------------------------
$.Questions['34']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Thinking about your physical health, which includes physical illness and injury, for how many days during the past 30 days was your physical health not good?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#numeric_answer',
		answer_units: ['days'],
		process_values: function(pageElement, nextQuestionButton){
				var values=[];
				// assuming the input elements have class="value" and data-unit="years", etc.
				$(pageElement).find('.value').each(function(valueIndex,valueElement){
						values[$(valueElement).attr('data-unit')]=parseInt($(valueElement).val());
					});
				$.Questionnaire.save({
						self_evaluated_times_physical_health_not_good: values['days']
					});
				$.Questionnaire.next('35'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//-----------------------------------Numeric_answers---------------------------------------------------------------------
$.Questions['35']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Thinking about your mental health, which includes stress, depression, and problems with emotions, for how many days during the past 30 days was your mental health not good?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#numeric_answer',
		answer_units: ['days'],
		process_values: function(pageElement, nextQuestionButton){
				var values=[];
				// assuming the input elements have class="value" and data-unit="years", etc.
				$(pageElement).find('.value').each(function(valueIndex,valueElement){
						values[$(valueElement).attr('data-unit')]=parseInt($(valueElement).val());
					});
				$.Questionnaire.save({
						perceived_mental_health: values['days']
					});
				$.Questionnaire.next('36'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//-----------------------------------Numeric_answers---------------------------------------------------------------------
$.Questions['36']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'During the past 30 days, for about how many days did poor physical or mental health keep you from doing your usual activities, such as self-care, work, or recreation?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#numeric_answer',
		answer_units: ['days'],
		process_values: function(pageElement, nextQuestionButton){
				var values=[];
				// assuming the input elements have class="value" and data-unit="years", etc.
				$(pageElement).find('.value').each(function(valueIndex,valueElement){
						values[$(valueElement).attr('data-unit')]=parseInt($(valueElement).val());
					});
				$.Questionnaire.save({
						days_poor_health_impacted_physical_activities: values['days']
					});
				$.Questionnaire.next('37'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.


//----------------------------------checkbox_text answer----------------------------------
$.Questions['37']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'What kind of health insurance do you have, if any?(check all that apply)',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#checkbox_text_answer',
		answer_choices: ['Medicaid', 'Medicare', 'VA', 'Private Insurance', 'None' ,'Other'],
		text_input: 'Specify',
		process_values: function(pageElement, nextQuestionButton){
				var obj={};
				// assuming the input elements have class="value" and data-unit="years", etc.
				
				$(pageElement).find('.choices').each(
						function(index, choice)
						{ 
							obj['health_insurance_provider_'+$(choice).val()] = $(choice).prop('checked'); 
						})
				
				obj.specify=$(pageElement).find('.tentry').first().val();

				$.Questionnaire.save(obj);
				$.Questionnaire.next('38'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

$.Questions['38']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Have you ever served in the US Military?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						served_in_military: nextQuestionButton.attr('data-choice-value')
					});
				if (nextQuestionButton.attr('data-choice-value')=='Yes')
					$.Questionnaire.next('39'); // if it's the last question, you can just $.Questionnaire.end();
				else
					$.Questionnaire.next('41'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//---------------------------------Radio Other--------------------------------------
$.Questions['39']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Which war/war era did you serve in?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_other_answer',
		answer_choices: ['Korean War (June 1950-January 1955)','Vietnam Era (August 1964-April 1975)', 'Post Vietnam (May 1975-July 1991)', 'Persian Gulf Era (August 1991-Present)', 'Afghanistan (2001-Present)', 'Iraq (2003-Present)', 'Refused to answer'],
		text_input: 'Other: ',
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						war: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('40'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//---------------------------------------------------------------------------------------------------
$.Questions['40']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Are you eligible for VA services?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						eligible_for_va_services: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('41'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//---------------------------------------------------------------------------------------------------
$.Questions['41']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Have you ever been in jail or prison?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						jail: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('42'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//---------------------------------------------------------------------------------------------------
$.Questions['42']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Have you ever been convicted of a felony?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						felony: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('43'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------checkbox_text answer----------------------------------
$.Questions['43']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'What are all of the different ways you\'ve made money in the past 6 months?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#checkbox_text_answer',
		answer_choices: ['Work, on-the-books', 'Work, off-the-books', 'SSI', 'SSDI/SSA', 'VA' ,'Public Assistance', 'Food Stamps', 'Sex Trade', 'Drug Trade', 'Recycling', 'Panhandling', 'No income', 'Pension/Retirement', 'None of the Above'],
		text_input: 'Other(specify)',
		process_values: function(pageElement, nextQuestionButton){
				var obj={};
				// assuming the input elements have class="value" and data-unit="years", etc.
				
				$(pageElement).find('.choices').each(
						function(index, choice)
						{ 
							obj['make_money_in_past_6_months_by_'+$(choice).val()] = $(choice).prop('checked'); 
						})
				
				obj.income=$(pageElement).find('.tentry').first().val();

				$.Questionnaire.save(obj);
				$.Questionnaire.next('44'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.


$.Questions['44']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'What is your gender?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Male','Female','Transgender','Other', 'Decline to State'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						gender: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('45'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.


//----------------------------------checkbox_text answer----------------------------------
$.Questions['45']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'What is your ethnicity?(check all that apply)',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#checkbox_text_answer',
		answer_choices: ['African American/Black', 'Asian', 'Native American', 'Native Alaskan', 'Native Hawaiian or Other Pacific Islander' ,'White', 'Mixed Race', 'Decline to State', 'Unknown', 'None of the Above'],
		text_input: 'Other(specify)',
		process_values: function(pageElement, nextQuestionButton){
				var obj={};
				// assuming the input elements have class="value" and data-unit="years", etc.
				
				$(pageElement).find('.choices').each(
						function(index, choice)
						{ 
							obj['ethnicity_'+$(choice).val()] = $(choice).prop('checked');
						})
				
				obj.race=$(pageElement).find('.tentry').first().val();
				
				$.Questionnaire.save(obj);
				$.Questionnaire.next('46'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

$.Questions['46']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Are you Married?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						married: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('47'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

$.Questions['47']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Do you have any children under 18 who live with you?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						children: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('48'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//---------------------------------Radio Other--------------------------------------
$.Questions['48']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'What is the highest grade in school you completed?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_other_answer',
		answer_choices: ['K-8','Some high school', 'High School Graduate', 'GED', 'Some College', 'College Graduate', 'Post Graduate', 'Decline to State'],
		text_input: 'Other: ',
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						education: nextQuestionButton.attr('data-choice-value'),
							 education2: $(pageElement).find('.tentry').first().val()
					});
				$.Questionnaire.next('49'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.


$.Questions['49']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'What is the reason for your current episode of homelessness?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['conflict with roommate','Poverty','Lack of affordable housing','Divorce', 'Domestic Violence', 'Lack of Child Support', 'Natural Disaster/fire','Tragedy(death of someone close)', 'Mental Illness','Illness','Jobless','Physical Disabilities'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						reason_for_current_episode_of_homelessness: nextQuestionButton.attr('data-choice-value')
					});
				$.Questionnaire.next('50'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.


$.Questions['50']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Is there a person/outreach worker that you trust more than others?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#radio_answer',
		answer_choices: ['Yes','No','Refused to answer'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						person_or_outreach_worker_that_is_trusted: nextQuestionButton.attr('data-choice-value')
					});
				if (nextQuestionButton.attr('data-choice-value')=='Yes')
					$.Questionnaire.next('51'); // if it's the last question, you can just $.Questionnaire.end();
				else
					$.Questionnaire.next('52'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

$.Questions['51']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Do you know their name and/or what agency they work for?',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#text_answer',
		answer_units: ['Contact'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						trusted_person_name_andOr_agency_contact: $(pageElement).find('.value').first().val()
					});
				$.Questionnaire.next('52'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------checkbox_text answer----------------------------------
$.Questions['52']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Surveyor, do you observe...(DO NOT ASK; check all that apply)',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#checkbox_text_answer',
		answer_choices: ['signs of not able to meet basic needs?(poor hyiene/clothing, unable to access food on own, no insight on needs)', 'signs of confusion, disorientation, evidence of dementia, or memory impairment?', 'signs of problematic social behavior?(responds in angry, profane, obscene, or verbally menacing ways, intimidating, difficulty engaging, yells, screams, or talks to self)'],
		text_input: 'Specify',
		process_values: function(pageElement, nextQuestionButton){
				var obj={};
				// assuming the input elements have class="value" and data-unit="years", etc.
				
				$(pageElement).find('.choices').each(
						function(index, choice)
						{ 
							obj['q52_observe_'+$(choice).val()]=$(choice).prop('checked'); 
						})
				obj.q52_specify=$(pageElement).find('.tentry').first().val();

				$.Questionnaire.save(obj);
				$.Questionnaire.next('53'); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.

//----------------------------------Text_anwers----------------------------------------------------------------------
$.Questions['53']={
		question_template_selector: '#normal_question', // in oppose to the "DO NOT ASK" questions
		question: 'Write additional notes on the following page',
		show_answers_selector: '.show_answer',
		
		answer_template_selector: '#text_answer',
		answer_units: ['Notes'],
		process_values: function(pageElement, nextQuestionButton){
				$.Questionnaire.save({
						last_additional_notes: $(pageElement).find('.value').first().val()
					});
				$.Questionnaire.end(); // if it's the last question, you can just $.Questionnaire.end();
			},
		next_question_selector: '.next_question',
	0:0}; // 0:0 added to make things simpler to move around above. Everything can have a , at the end now.


